
import java.util.Random;



public class AISearching {

    /**
     * @param args
     */
    public static Equation equation;
    private static Random rand = new Random(System.currentTimeMillis());

    public static class CreateCNF {

        /** Returns a randomly generated 3-SAT instance, as a String.  All
        sentences are drawn from a world of 26 variables, A-Z.
        <code>numClauses</code> is the number of disjunctive clauses to
        generate. */
        public static String randInstance(int numClauses, int numLiterals) {
            StringBuffer sb = new StringBuffer(randDisjunction(numLiterals));
            for (int i = 1; i < numClauses; i++) {
                sb.append(randDisjunction(numLiterals));
            }
            return sb.toString();
        }

        /** Returns a disjunction of three literals chosen by randLiteral() */
        public static String randDisjunction(int numLiteral) {
            return "(" + randNumber(numLiteral) + "#" + randNumber(numLiteral) + "#" + randNumber(numLiteral) + ")";
        }

        public static String randNumber(int numLiterl){
            return (coinFlip() ? "-" : "") +Integer.toString(rand.nextInt(numLiterl));
        }

        /** Returns a random literal, as a string.  The variable of the
        literal is drawn uniformly from 'A'-'Z', and negated with
        probability 0.5. */
        public static String randLiteral(int numLiteral) {
            return (coinFlip() ? "-" : "") + (char) ('A' + randInt(0, numLiteral - 1));
        }

        /** Returns true with probability 0.5. */
        public static boolean coinFlip() {
            return (Math.random() < 0.5);
        }

        /** returns a random integer between a and b, inclusive. */
        public static int randInt(int a, int b) {
            return ((int) (Math.floor(Math.random() * (b - a + 1)) + a));
        }
    }

    //static String c = "(M#Y#-T)(-Z#-J#P)(I#O#-I)(-E#-C#-X)(-P#I#T)(D#A#K)(U#-B#C)(V#S#-L)(-R#-A#N)(V#S#-E)(-H#M#T)(Z#O#-R)(Z#S#I)(-J#Q#-N)(W#Y#Q)(-F#K#X)(-X#V#K)(-G#-R#J)(F#J#Y)(-O#-H#H)(J#L#-Z)(-A#-W#-P)(W#J#T)(I#-E#-L)(A#-N#G)(-L#S#M)(X#-Q#R)(G#K#V)(-V#-I#-Z)(-J#H#L)(-Q#-P#Z)(Y#-X#-P)(F#-F#W)(F#K#V)(L#U#-P)(-K#-B#-I)(K#-S#-I)(Z#-A#-B)(-S#-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